package com.tim.app.ui.adapter.someone_homepage;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.application.library.util.PhoneUtil;
import com.application.library.widget.recycle.BaseRecyclerAdapter;
import com.application.library.widget.roundimg.RoundedImageView;
import com.tim.app.R;
import com.tim.app.util.BitmapLoader;

import java.util.List;


/**
 * 内容列表的适配器
 */
public class PriseAvatarAdapter extends BaseRecyclerAdapter<BaseRecyclerAdapter.BaseRecyclerViewHolder, String> {

    private Context mContext;

    public PriseAvatarAdapter(Context mContext, List<String> mDataList) {
        super(mDataList);
        this.mContext = mContext;
    }

    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseRecyclerViewHolder holder = null;
        holder = new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_prise_avatar, null));
        return holder;
    }

    @Override
    public void onBindViewHolder(BaseRecyclerViewHolder mHolder, int position, String data) {

        if (null == data)
            return;
        ViewHolder holder = (ViewHolder) mHolder;
        RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(PhoneUtil.dipToPixel(28, mContext), PhoneUtil.dipToPixel(28, mContext));
        holder.itemView.setLayoutParams(params);
        if (!TextUtils.isEmpty(data)) {
            BitmapLoader.ins().loadImage(data,holder.rivPriseAvatar);
        }
    }


    public class ViewHolder extends BaseRecyclerViewHolder {

        RoundedImageView rivPriseAvatar;

        public ViewHolder(View itemView) {
            super(itemView);
            rivPriseAvatar = (RoundedImageView) itemView.findViewById(R.id.rivPriseAvatar);
        }

    }

}
